const global = require('../global')
const util = require('../util')
const top = util.getTop()
const topMapping = {
  '专题': {
    icon: 'icon-zhuanti'
  },
  '优化': {
    icon: 'icon-optimizationcog'
  },
  '小功能': {
    icon: 'icon-gongneng'
  },
  '工具使用': {
    icon: 'icon-tool'
  },
  '源码阅读': {
    icon: 'icon-code'
  },
  '知识整理': {
    icon: 'icon-zhishi'
  },
  '读书笔记': {
    icon: 'icon-yuedushuben'
  },
  '课程': {
    icon: 'icon-biaoqianA01_kecheng-96'
  },
  '面试题': {
    icon: 'icon-mianshitiku'
  }
}

module.exports = async ctx => {
  await ctx.render('home', {
    links: global.links,
    list: top.map(k => ({
      name: k,
      ...topMapping[k]
    }))
  })
}